
[dbo].[RegistrationStatusChange]
CREATE TABLE [dbo].[RegistrationStatusChange]
(
[RegistrationStatusChangeKey] [uniqueidentifier] NOT NULL,
[CertificationProgramRegistrationKey] [uniqueidentifier] NOT NULL,
[RegistrationStatusCode] [char] (2) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[RegistrationStatusChangeNote] [nvarchar] (250) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[StatusChangedOn] [datetime] NOT NULL,
[StatusChangedUserKey] [uniqueidentifier] NOT NULL,
[UpdatedOn] [datetime] NOT NULL,
[UpdatedByUserKey] [uniqueidentifier] NOT NULL,
[CreatedOn] [datetime] NOT NULL,
[CreatedByUserKey] [uniqueidentifier] NOT NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[RegistrationStatusChange] ADD CONSTRAINT [PK_RegistrationStatusChange] PRIMARY KEY CLUSTERED ([RegistrationStatusChangeKey]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_RegistrationStatusChange_CertificationProgramRegistrationKey] ON [dbo].[RegistrationStatusChange] ([CertificationProgramRegistrationKey]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_RegistrationStatusChange_CreatedByUserKey] ON [dbo].[RegistrationStatusChange] ([CreatedByUserKey]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_RegistrationStatusChange_RegistrationStatusCode] ON [dbo].[RegistrationStatusChange] ([RegistrationStatusCode]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_RegistrationStatusChange_StatusChangedUserKey] ON [dbo].[RegistrationStatusChange] ([StatusChangedUserKey]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_RegistrationStatusChange_UpdatedByUserKey] ON [dbo].[RegistrationStatusChange] ([UpdatedByUserKey]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[RegistrationStatusChange] ADD CONSTRAINT [FK_RegistrationStatusChange_CertificationProgramRegistration] FOREIGN KEY ([CertificationProgramRegistrationKey]) REFERENCES [dbo].[CertificationProgramRegistration] ([CertificationProgramRegistrationKey])
GO
ALTER TABLE [dbo].[RegistrationStatusChange] ADD CONSTRAINT [FK_RegistrationStatusChange_RegistrationStatusRef] FOREIGN KEY ([RegistrationStatusCode]) REFERENCES [dbo].[RegistrationStatusRef] ([RegistrationStatusCode])
GO
ALTER TABLE [dbo].[RegistrationStatusChange] ADD CONSTRAINT [FK_RegistrationStatusChange_UserMain_CreatedBy] FOREIGN KEY ([CreatedByUserKey]) REFERENCES [dbo].[UserMain] ([UserKey])
GO
ALTER TABLE [dbo].[RegistrationStatusChange] ADD CONSTRAINT [FK_RegistrationStatusChange_UserMain_StatusChanged] FOREIGN KEY ([StatusChangedUserKey]) REFERENCES [dbo].[UserMain] ([UserKey])
GO
ALTER TABLE [dbo].[RegistrationStatusChange] ADD CONSTRAINT [FK_RegistrationStatusChange_UserMain_UpdatedBy] FOREIGN KEY ([UpdatedByUserKey]) REFERENCES [dbo].[UserMain] ([UserKey])
GO